﻿@model IEnumerable<SienSchoofsProject.Models.Film>

@{
    ViewBag.Title = Resources.MovieList;
}

<hgroup class="title">
    <h1>@ViewBag.Title</h1>
</hgroup>

<p>
    @if (User.IsInRole("admin"))
    {
        @Html.ActionLink(Resources.AddMovieTitle, "Create")
    }
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Year)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Director)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Year)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Director)
            </td>
            <td>
                @if (User.IsInRole("admin"))
                {
                    @Html.ActionLink(Resources.Edit, "Edit", new { id = item.Id }) @("|") 
                }
                @Html.ActionLink("Reviews", "Index", "Reviews", new { id = item.Id }, null)
                @if (User.IsInRole("admin"))
                {
                    @("|") @Html.ActionLink(Resources.Delete, "Delete", new { id = item.Id })
                }
            </td>
        </tr>
    }

</table>
